class Solution(object):
    def numberOfCombinations(self, num):
        if num[0] == '0':
            return 0
        n = len(num)
        base = 10 ** 9 + 7
        DP = [[0 for _ in range(n)] for _ in range(n)]
        prefix = [[0 for _ in range(n)] for _ in range(n)]
        for j in range(n):
            for i in range(j, -1, -1):
                if j == 0:
                    DP[i][j] = 1
                    prefix[i][j] = 1
                else:
                    if i == j:
                        if num[j] != '0' and num[j] >= num[i - 1]:
                            DP[i][j] = DP[i - 1][j - 1]
                            prefix[i][j] = DP[i][j]
                    else:
                        if num[i] > '0':
                            if i == 0:
                                DP[i][j] = 1
                            else:
                                prefix_i = 2 * i - j - 1
                                if prefix_i < 0:
                                    DP[i][j] = prefix[0][i - 1]
                                else:
                                    if num[prefix_i] > '0' and num[prefix_i: i] <= num[i: j + 1]:
                                        DP[i][j] = prefix[prefix_i][i - 1]
                                    else:
                                        DP[i][j] = prefix[prefix_i + 1][i - 1]
                        prefix[i][j] = (DP[i][j] + prefix[i + 1][j]) % base
        ans = 0
        for i in range(n):
            ans = (ans + DP[i][n - 1]) % base
        return ans
             

                        

                            




data = Solution()
num = "9999"
print(data.numberOfCombinations(num))